// Tạo ra 1 Client
var wsClient = require('websocket').client;

new wsClient()
	.on('connect', function (connect){
		var msg = 'Hello';		//msg từ phía client

		connect.send(msg);		//
		console.log('Sent: ' + msg);

		connect.on('message', function (msg){
			console.log('Recieved: ' + msg.utf8Data);
		}).on('close', function (code, desc){
			console.log('Disconnected: ' + code + ' - ' + desc);
		}).on('error', function (error){
			console.log('Error: ' + error.toString());
		});
	}).on('connectFailed', function (error){
		console.log('Connect error: ' + error.toString());
	}).connect('ws://localhost:8080', null, 'http://localhost:8080');